#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int num[1000] = { 6,2,5,5,4,5,6,3,7,6};
int path[10];
int n,cnt = 0;
int usenum=0;
void dfs()
{
	for (int i = 10; i <1000; i++)
	{
		num[i] = num[i % 10] + num[i / 10];
	}
	for (int i = 0; i <= 999; i++)
	{
		path[0] = i;
		for (int j = 0; j <= 999; j++)
		{
			path[1] = j;
			for (int k = 0; k <= 999; k++)
			{
				path[2] = k;
				if (path[0] + path[1] == path[2] && num[i] + num[j] + num[k] == n - 4)
				{
					cnt++;
					printf("%d %d %d\n", path[0], path[1], path[2]);
				}
			}
		}
	}
}
int main()
{
	scanf("%d", &n);
	dfs();
	printf("%d",cnt);
	return 0;
}


